# list of x64 registers

rax
rbx
rcx
rdx
rdi
rsi
rbp
rsp
r8-r15


# arithmetic, special registers

div and mul use
 * rax
 * rdx


# syscall convention

https://github.com/torvalds/linux/blob/master/arch/x86/entry/entry_64.S#L124
https://github.com/torvalds/linux/blob/master/arch/x86/entry/syscalls/syscall_64.tbl
https://github.com/torvalds/linux/blob/14155cafeadda946376260e2ad5d39a0528a332f/include/linux/syscalls.h

 * rax  system call number
 * rcx  return address
 * r11  saved rflags (note: r11 is callee-clobbered register in C ABI)
 * rdi  arg0
 * rsi  arg1
 * rdx  arg2
 * r10  arg3 (needs to be moved to rcx to conform to C ABI)
 * r8   arg4
 * r9   arg5
 


# OUR CODING CONVENTION

rax [BUILTIN ARG1] [RETURN REGISTER] [TEMPORARY]
rbx [ENV REGISTER]
rcx (gets destroyed by syscalls)
rdx (destroyed by mul/div)
rdi (gets destroyed by syscall)
rsi (gets destroyed by syscall)
rbp [BASE POINTER]
rsp [STACK POINTER]
r8-r15
